package com.xiaomi.service.impl;

import com.xiaomi.entity.Fenlei;
import com.xiaomi.mapper.FenLeiMapper;
import com.xiaomi.service.FenLeiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName ShopSpuServiceImpl
 * @Description TODO
 * @Author yp
 * @Date 2021/11/28 12:14
 * @Version 1.0
 **/
@Service
public class FenLeiServiceImpl implements FenLeiService {
    @Autowired
    private FenLeiMapper fenLeiMapper;

    @Override
    public List<Fenlei> query() {
        List<Fenlei> typeList = fenLeiMapper.fenleiFather(0);
        for (Fenlei firstType : typeList) {
            firstType.setChildren(fenLeiMapper.fenleiFather(firstType.getId()));
        }
        return typeList;
    }

    @Override
    @Transactional
    public void insert(Fenlei fenlei) {
        fenLeiMapper.insert(fenlei);
    }

    @Override
    @Transactional
    public void update(Fenlei fenlei) {
        fenLeiMapper.update(fenlei);

    }

    @Override
    public void delete(Integer id)  {
        fenLeiMapper.delete(id);

    }




    }
